package com.ts.api.common.util;

import com.gitee.apanlh.util.base.StringUtils;

/**
 * @author Pan
 */
public class ExceptionUtils {

    /**
     *  获取堆栈信息
     *
     *  @param  e
     *  @return String
     */
    public static String getStackTrace(Throwable e) {
        StringBuilder sb = StringUtils.createBuilder(e).append("\n");
        StackTraceElement[] stackTrace = e.getStackTrace();

        for (int i = 0; i < stackTrace.length; i++) {
            StackTraceElement stackTraceElement = stackTrace[i];

            String stackTraceElementString = stackTraceElement.toString();
            if (stackTraceElementString.contains("com.ts")) {
                sb.append("\t" + stackTraceElementString).append("\n");
            }
        }

        return sb.toString();
    }

}
